#include <qwt_plot.h>
#include "cpustat.h"
#define  NValues 2
#define HISTORY 60 // seconds

class QwtPlotCurve;

class CpuPlot : public QwtPlot 
{
    Q_OBJECT
public:
    enum CpuData
    {
        Data1,
        Data2,
        Data3,
        Data4,

        NCpuData
    };

    CpuPlot(QWidget * = 0);
    const QwtPlotCurve *cpuCurve(int id) const
        { return data[id].curve; }
    void statistic(double &data1, double &data2);
protected:
    void timerEvent(QTimerEvent *e);

private Q_SLOTS:
    void showCurve(QwtPlotItem *, bool on);

private slots:
    void setPacketData(QByteArray *p);
    void slotSetAxisScale(qint16 min16,qint16 max16)//调整Y范围
    {
        setAxisScale(QwtPlot::yLeft, min16, max16);
    }
private:
    struct
    {
        QwtPlotCurve *curve;
        double data[HISTORY];//同一条曲线上不同x值处的点
    } data[2];

    double timeData[HISTORY];
   // double procValues[NValues];
    int dataCount;
    QByteArray packetData; //接收到的数据包中的数据
};
